


#ifndef _CDIB_H_
#define _CDIB_H_

#include <windows.h>

class CDIB
{
protected:
	
	BITMAPFILEHEADER m_fh;
	LPBITMAPINFOHEADER m_pIH;
	void*			 m_pColorTable;
	BYTE*			 m_pImg;
	POINT			 m_Dimen;

	HPALETTE		 m_hPalette;
	int m_nColorTableEntries;

	DWORD m_dwImgSize;
	
	bool MakePalette();
	void ComputeColorTableSize(int nBitCount);
	void ComputeImgSize();

public:

	void Clear();

	HBITMAP MakeDDB(HDC* pDC);
	CDIB*   MakeDIB(HBITMAP hBm);
	BYTE*	GetImage();
	const LPBITMAPINFOHEADER GetImageInfo();

	
	void DrawDIB(HDC* pDC, POINT pt, RECT* pRect=NULL);
	void DrawDIB(HDC* pDC, RECT* pRect=NULL);

	void SetDimension(int w, int h);
	POINT GetDimension();
	

	void Save(char* szFileName);
	void Load(char* szFileName);


	CDIB();
	~CDIB();
};




#endif